home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / c-tools / c_examples / slider / slider.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-22  |  1.8 KB  |  88 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. // gadget.cpp
  3. //
  4. // Jeffry A Worth
  5. // November 10, 1995
  6. //////////////////////////////////////////////////////////////////////////////
  7.  
  8. //////////////////////////////////////////////////////////////////////////////
  9. // INCLUDES
  10. #include "aframe:include/slider.hpp"
  11.  
  12. //////////////////////////////////////////////////////////////////////////////
  13. //
  14.  
  15. AFSlider::AFSlider()
  16. {
  17.   m_iMax = m_iCount = m_iPos = 0;
  18. }
  19.  
  20. AFSlider::~AFSlider()
  21. {
  22.   DestroyObject();
  23. }
  24.  
  25. void AFSlider::FillGadgetStruct(LPGadget psgadget)
  26. {
  27.   psgadget->Flags = NULL;
  28.   psgadget->Activation = GACT_RELVERIFY|GACT_IMMEDIATE;
  29.   psgadget->GadgetType = GTYP_PROPGADGET;
  30.   psgadget->GadgetRender = (APTR)&m_image;
  31.   psgadget->SelectRender = NULL;
  32.   psgadget->GadgetText = NULL;
  33.   psgadget->MutualExclude = NULL;
  34.   psgadget->SpecialInfo = (APTR)&m_propinfo;
  35.   return;
  36. }
  37.  
  38. void AFSlider::Create(AFWindow* pwindow, AFRect *rect, ULONG id, UWORD iFlags)
  39. {
  40.   Create(pwindow,rect,id,iFlags,1,1,1);
  41. }
  42.  
  43. void AFSlider::Create(AFWindow* pwindow, AFRect *rect, ULONG id, UWORD iFlags, int iMax, int iCount, int iPos)
  44. {
  45.   double size;
  46.  
  47.   // Store Information
  48.   m_iMax=iMax;
  49.   m_iCount=iCount;
  50.   m_iPos=iPos;
  51.  
  52.   // Setup the PropInfo Structure
  53.   size = m_iCount;
  54.   size*=(0xffff/m_iMax);
  55.   m_propinfo.Flags = iFlags | PROPNEWLOOK | AUTOKNOB;
  56.   m_propinfo.HorizBody = MAXBODY; // FIXED TO VERTICLE FOR THE TIME BEING !!!!!!!!!!!!!!!!
  57.   m_propinfo.VertBody = size;
  58.  
  59.   // Create the gadget
  60.   AFGadget::Create(pwindow,rect,id);
  61. }
  62.  
  63. int AFSlider::SetMax(int iMax)
  64. {
  65.   return iMax;
  66. }
  67.  
  68. int AFSlider::SetCount(int iCount)
  69. {
  70.   return iCount;
  71. }
  72.  
  73. int AFSlider::SetPos(int iPos)
  74. {
  75.   return iPos;
  76. }
  77.  
  78. int AFSlider::CurrentPos()
  79. {
  80.   double pos;
  81.  
  82.   pos = m_propinfo.VertPot+2*(0xFFFF/m_iMax);
  83.   pos /= 0xFFFF;
  84.   if(m_iMax>m_iCount)
  85.     return pos*(m_iMax-m_iCount)+1;
  86.   return 0;
  87. }
  88.